import React, {Component} from 'react'
import {Form, Select, Input,} from 'antd'
import PropTypes from 'prop-types'
const Item = Form.Item
const Option = Select.Option

//更新分类
class UpdateForm extends Component {

    static propTypes = {
        username: PropTypes.string.isRequired,
        setForm: PropTypes.func.isRequired
    }

    componentWillMount() {
        //将form对象通过setForm（）传递父组件
        this.props.setForm(this.props.form)
    }

    render() {
        const {username} = this.props
        const {getFieldDecorator} = this.props.form
        return (
            <Form>
                <Item>
                    {
                        getFieldDecorator('username',{
                            initialValue: username,
                            rules: [
                                {required: true,message:'分类名称必须输入'}
                            ]
                        })(
                            <Input placeholder='请输入分类名称'/>
                        )
                    }
                </Item>
            </Form>
        )
    }
}


export default Form.create()(UpdateForm)